#include "AutoRecycleBuffer.h"

#include "Render/VulkanContext.h"
#include "Render/VulkanRecycleObjects.h"

SVulkanAutoRecycleBuffer::~SVulkanAutoRecycleBuffer()
{
    ClearBuffer();
}

void SVulkanAutoRecycleBuffer::ClearBuffer()
{
    if(Buffer)
    {
        CVulkanContext::Get()->GetRecycleObjects()->Buffers.Add(Buffer);
        Buffer=nullptr;
    }

    if(MemoryBlock.IsValid())
    {
        CVulkanContext::Get()->GetRecycleObjects()->MemoryBlocks.Add(MemoryBlock);
        MemoryBlock=SVulkanMemoryBlock();
    }
}